<template>
  <div>
    <van-row gutter="10">
      <van-col
        v-for="(item, index) in typeList"
        :key="index"
        :span="8"
        style="display: flex; justify-content: center; margin-top: 20px"
      >
        <div style="text-align: center">
          <router-link :to="{path:'/product',query:{typeid:item.id}}">
            <van-image
              width="100"
              height="100"
              fit="cover"
              :src="item.thumb_text"
            />
            <div style="margin-top: 8px">{{ item.name }}</div>
          </router-link>
        </div>
      </van-col>
    </van-row>
  </div>
</template>


<script setup>

const { proxy } = getCurrentInstance();
const typeList = ref([]);

onBeforeMount(() => {
  GetHomeData();
});

const GetHomeData = async () => {
  let result = await proxy.$http.post({
    url: "/product/type",
  });

  console.log(result);

  if (result.code === 1) {
    typeList.value = result.data;
  }
};
</script>
